import { GlobalStyle } from "../../../../common/global/GlobalStyle";
import { ObjCreate } from "../../common/ObjCreate";
import { LoaderHelp } from "../../../../common/display/LoaderHelp";
import { ResFileConst } from "../../../resource/ResFileConst";
import { SDominionCity } from "../../../../../Message/Public/SDominionCity";
import { EffectManager } from "../../../manager/EffectManager";
import { FilterConst } from "../../../../component/gconst/FilterConst";
import { ImagesConst } from "../../../resource/ImagesConst";
import { EDominionCountryForce } from "../../../../../Message/Public/EDominionCountryForce";
import { GlobalClass } from "../../../../../com/mui/core/GlobalClass";
import { GTextFiled } from "../../../../../com/mui/controls/GTextFiled";
//class WorldForceCityCell
    
    export  class WorldForceCityCell /* flash.display.Sprite */
    {
        constructor()
        {
            
            this.configUI();
            return;
        }

        public get isMain(): Boolean
        {
            return this._isMain;
        }

        public set isMain(arg1: Boolean)
        {
            this._isMain = arg1;
            if (this._isMain) 
            {
                this.setCityBmp();
            }
            return;
        }

        /* internal  */configUI(): void
        {
            this._cityBmp = new Object /* flash.display.Bitmap */();
            this.addChild(this._cityBmp);
            var loc1=GlobalStyle.textFormat1.clone();
            loc1.align = "center";
            this._nameTxt = ObjCreate.createGTextField("", 0, 0, 100, 20, this, loc1);
            LoaderHelp.addResCallBack(ResFileConst.dominionWarBeacon, this.onImageLoaded);
            return;
        }

        /* internal  */onImageLoaded(): void
        {
            this._isLoaded = true;
            this.setCityBmp();
            return;
        }

        public get data(): SDominionCity
        {
            return this._data;
        }

        public set data(arg1: SDominionCity)
        {
            this._data = arg1;
            this._isUpdate = true;
            this._nameTxt.text = this._data.name;
            if (this._data.isLight) 
            {
                EffectManager.glowFilterReg(this, [FilterConst.warnningFilter]);
            }
            else 
            {
                EffectManager.glowFilterUnReg(this);
            }
            this.setCityBmp();
            return;
        }

        /* internal  */setCityBmp(): void
        {
            var loc1=null;
            if (this._isLoaded) 
            {
                loc1 = "";
                if (this._isMain) 
                {
                    loc1 = ImagesConst.DwbCity_Main;
                }
                else if (this._isUpdate) 
                {
                    var loc2=this._data.force;
                    switch (loc2) 
                    {
                        case EDominionCountryForce._EDominionForceImmortal:
                        {
                            loc1 = ImagesConst.DwbCity_yellow;
                            break;
                        }
                        case EDominionCountryForce._EDominionForceHumanWorld:
                        {
                            loc1 = ImagesConst.DwbCity_blue;
                            break;
                        }
                        case EDominionCountryForce._EDominionForceDevil:
                        {
                            loc1 = ImagesConst.DwbCity_green;
                            break;
                        }
                    }
                }
                if (loc1 != "") 
                {
                    this._cityBmp.bitmapData = GlobalClass.getBitmapData(loc1);
                    this._cityBmp.x = (-this._cityBmp.width) / 2;
                    this._cityBmp.y = -this._cityBmp.height;
                    this._nameTxt.width = this._cityBmp.width;
                    this._nameTxt.x = this._cityBmp.x;
                    this._nameTxt.y = this._cityBmp.y - this._nameTxt.height - 3;
                }
            }
            return;
        }

        /* internal */ /* var */_data: SDominionCity;

        /* internal */ /* var */_cityBmp: Object /* flash.display.Bitmap */;

        /* internal */ /* var */_nameTxt: GTextFiled;

        /* internal */ /* var */_isLoaded: Boolean;

        /* internal */ /* var */_isUpdate: Boolean;

        /* internal */ /* var */_isMain: Boolean;
    }
